/**
 * 
 */
package gameEngine;

import java.util.Hashtable;

/**
 * @author Joe R. Nassimian
 * @author Yannis Mazzer
 */
public class GamesList extends Hashtable<String, String[]> {

	/**
	 * Eclipse generated serial number.
	 */
	private static final long serialVersionUID = -8573842899453636105L;
	/*
	 * We create the String array containing the name of playable games;
	 * every time we create a new game implementing this BoardGame engine,
	 * we add the name to the list.
	 */
	private final String[] gamesPossible = {"Backgammon","Blokus","Chess"};
	// Game Specific data
	// // Backgammon board shapes
	private final String[] backgammonShapes = {"Square"};
	// // Blokus board shapes
	private final String[] blokusShapes = {"Square","Triangle"};
	// // Chess board shapes
	private final String[] chessShapes = {"Square"};
	// // Boardshapes per game array
	private final String[][] boardShapes = {backgammonShapes,blokusShapes,chessShapes};
	private ShapeSpecs shapeSpecs;
	
	public GamesList(){
		if (gamesPossible.length == boardShapes.length){
			for(int i = 0 ; i < gamesPossible.length ; i++){
				this.put(gamesPossible[i],boardShapes[i]);
			}
			setShapeSpecs(new ShapeSpecs(this));
		}
		
	}
	
	public String[] getGamesArray(){
		return (String[]) this.keySet().toArray(new String[0]);
	}
	
	public String[] getBoardShapes(String _game){
		return get(_game);
	}

	public Integer[] getBoardShapeDimensions(String _name, String _shape){
		return getShapeSpecs().getBoardDim(_name, _shape);
	}
	
	public Integer[] getBoardShapeNbPlayers(String _name, String _shape, int _dim){
		return getShapeSpecs().getBoardNbPlayers(_name, _shape, _dim);
	}
	
	public int getBoardshapeEdgeSize(String _name, String _shape, int _dim){
		return getShapeSpecs().getBoardEdgeSize(_name, _shape, _dim);
	}
	
	/**
	 * @param shapeSpecs the shapeSpecs to set
	 */
	public void setShapeSpecs(ShapeSpecs shapeSpecs) {
		this.shapeSpecs = shapeSpecs;
	}

	/**
	 * @return the shapeSpecs
	 */
	public ShapeSpecs getShapeSpecs() {
		return shapeSpecs;
	}
}
